<template>
	<view class="content">
		<mydefault type="1" :showflag="showflag" ></mydefault>
		<view class="cost_info" v-for="(item,index) in list">
			<text class="cost_time"> {{item.create_time}}</text>
			<view class="cost_con">
				<view class="cost_con_in">
					<image class="cost_con_img" :src="imgUrl+'/static/wap/infoImg/news@2x.png'"></image>
					<text class="cost_con_tz">{{item.notice_name}}</text>
				</view>
				<view class="cost_con_txt">
					{{item.notice_content}}
				</view>
			</view>
		</view>
		<uLi-load-more v-if="list.length>=5" :status="loadingType" :contentText="contentText" ></uLi-load-more>
		
	</view>
</template>

<script>
	import uLiLoadMore from "@/components/uLi-load-more/uLi-load-more.vue"
	import mydefault from '@/components/default/default.vue';
	import util from '../../static/util.js'
	export default {
		components:{
		mydefault,
		uLiLoadMore
		},
		data() {
			return {
				showflag:false,
				imgUrl:util.globalData.imgPre,
               page:1,
			   list:'',
			   loadingText: '加载中...',
			   loadingType: 'more',//定义加载方式 0---contentdown  1---contentrefresh 2---contentnomore
			   contentText: {
			          contentdown:'上拉显示更多',
			          contentrefresh: '正在加载...',
			          contentnomore: '没有更多数据了',
			    },
			};
		},
		onLoad(){
			this.getNoticeList()
		},
		onReachBottom(){
			this.page=this.page+1
			this.getNoticeList()
		},
		methods:{
			getNoticeList(){
				var that=this;
				that.ajax({
					url:'api/Notice/getNoticeList',
					data:{
						page:that.page,
						type:2
					},
					success:function(res){
						console.log(res)
						if(res.code!=200||res.data.length<=0){
							that.showflag=true
							return
						}
						if(that.page==1){
							that.list=res.data
						} 
						if(that.page>1){ 
							if(res.data.length>0){
								that.list=that.list.concat(res.data)
								that.loadingType = 'more';//将loadingType归0重置
								uni.hideNavigationBarLoading();//关闭加载动画
							}else{  
								that.loadingType = 'noMore';//将loadingType归0重置
								uni.hideNavigationBarLoading();//关闭加载动画
							}
						}
						
					}
				  })
			}
		}
	}
</script>

<style lang="less" scoped>
	.content{
		background: #F7F9FB;
		min-height: 100vh;
	}
	.cost_info {
		padding: 10rpx;
		color: #333; 

		.cost_time {
			margin: 30rpx auto;
			display: block;
			width: 310rpx;
			height: 60rpx;
			line-height: 60rpx;
			font-size: 24rpx;
			color: #fff;
			text-align: center;
			background: #BFBFBF;
			opacity: 0.74;
			border-radius: 30rpx;
		}

		.cost_con {
			padding: 0 30rpx 30rpx 30rpx;
			height: 240rpx;
			background: url('https://nengyuan.chuangxiangdianli.com/static/wap/infoImg/tu_bg@2x.png') no-repeat;
			background-size: 100% 100%;

			.cost_con_in {
				font-size: 30rpx;
				height: 100rpx;
				line-height: 100rpx; 

				.cost_con_img {
					margin-right: 40rpx;
					width: 50rpx;
					height: 50rpx;
				}
			}

			.cost_con_txt {
				padding: 0 20rpx;
				font-size: 26rpx;
				height: 140rpx;
				line-height: 44rpx;
				display: -webkit-box;
				text-overflow: ellipsis;
				overflow: hidden;
				-webkit-line-clamp: 3;
				-webkit-box-orient: vertical;
			}
		}
	}
</style>
